@extends('layouts.admin')
@section('title') @parent 文章分类管理 @stop
@section('page_title')@parent
文章分类
@show
@section('breadcrumb')@parent
{{ Breadcrumbs::render('article-class-index') }}
@show
@section('content')
<div class="box">
	<div class="box-header">
		<h3 class="box-title">文章分类</h3>
	</div>
	<div class="box-body table-responsive">
		@include('widgets.notification')
		<div class="pad"><button class="btn btn-primary pull-right" type="button" onclick="location.href='{{ route('admin.article_class.create') }}'"><i class="fa fa-plus"></i> 添加分类</button></div>
		<table id="example2" class="table table-bordered table-hover">
			<thead>
				<tr>
					<th>ID</th>
					<th>名称</th>
					<th>上级分类</th>
					<th>排序</th>
					<th>关键字</th>
				   <th>操作</th>
				</tr>
			</thead>
			<tbody>
			@foreach($article_classes as $cat)
				<tr>
					<td>{{  $cat->id }}</td>
					<td>{{ $cat->name }}</td>
					<td>{{ $cat->parentClass()->name}}</td>
					<td>{{ $cat->orders }}</td>
					<td>{{ $cat->keys }}</td>
					<td><a href="{{ route('admin.article_class.edit', $cat->id) }}">&nbsp;&nbsp;<span class="glyphicon glyphicon-edit"></span></a> <a href="javascript:void(0)" id="d_{{ $cat->id }}" class="btn-del">&nbsp;&nbsp;<span class="glyphicon glyphicon-remove danger"></span></a></td>
				</tr>
			 @endforeach
			</tbody>
		</table>
	</div>
</div>

@stop
@section('end') @parent
<script type="text/javascript">
$(function() {
		$(document).on('click', '.btn-del', function(){
			if(confirm("你确定要删除该文章分类么？"))
			{
					var $id = $(this).attr("id").split('_')[1];
					$('<input type="hidden" name="_method" value="DELETE" />').insertAfter(this);
					$('.frm').attr('action', "/admins/article-category/" + $id);
					$('.frm').submit();
			}
		})
});
</script>
@stop